﻿namespace My.Hydrator.Formatters
{
    using System.ComponentModel.Composition;
    using System.ComponentModel.DataAnnotations;
    using My.Hydrator.Helpers;

    [Export(typeof(IDataTypeFormatter))]
    public class TextDataTypeFormatter : BaseDataTypeFormatter, IDataTypeFormatter
    {
        private readonly int stringLength;

        public TextDataTypeFormatter() : this(100)
        {
        }

        public TextDataTypeFormatter(int stringLength)
        {
            this.stringLength = stringLength;
        }

        public virtual DataTypeAttribute FormatterDataType
        {
            get { return new DataTypeAttribute(DataType.Text); }
        }

        public virtual object GetFormat()
        {
            var result = string.Empty;

            for (var i = 0; i < this.stringLength; i++)
            {
                result += this.Random.NextUpperCaseLetter();
            }

            return result;
        }
    }
}
